﻿#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ESF.SSO.Core.Entities.BasicReferences;
using ESF.General;
using ESF.SSO.Presenter.Admin;
using ESF.Web;
using ESF.General.Entity;

#endregion


public partial class BasicReference_EditBasicReferenceValues : System.Web.UI.UserControl
{
    #region Carga Inicial
    
    protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
		{
		}
	}

    #endregion


	#region Propiedades

	public List<BasicReference> Values
	{
		get
		{
			List<BasicReference> result;


			result = new List<BasicReference> (grvBasicReferences.Rows.Count);

			foreach (GridViewRow row in grvBasicReferences.Rows)
			{
				result.Add (
					new BasicReference ()
					{
						ID = GridLoader.GetValueIDForRow (row),
						Value = (row.FindControl ("ddlValue") as DropDownList).SelectedValue
					});
			}

			return result;
		}
		set
		{
			GridLoader.LoadGrid <BasicReference> (grvBasicReferences, value);
		}
	}

	#endregion


	#region Eventos de la Grilla

	protected void grvBasicReferences_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		BasicReference value;

		
		value = e.Row.DataItem as BasicReference;


		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			GridLoader.SetValueIDForRow (e.Row, value.ID.Value);

			(e.Row.FindControl ("ddlValue") as DropDownList).SelectedValue = value.Value;
		}
	}

	#endregion
}
